package com.flowCloud.web.controller.tbl_log;

import com.flowCloud.result.LayDatas;
import com.flowCloud.result.ResultModel;
import com.flowCloud.result.ResultTools;
import com.flowCloud.config.log.SystemControllerLog;
import com.flowCloud.web.controller.tbl_log.vo.*;
import com.flowCloud.web.service.tbl_log.*;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.flowCloud.web.bean.*;

import java.util.List;

/**
 * @Author: 系统自动生成
 * @Date: 2021-01-18
 * @Description: TblLogController 控制层
 */
@Slf4j
@RestController
@RequestMapping("tblLogCon")
public class TblLogController {

    @Autowired
    private TblLogService tblLogService;

    /**
     * @Description: 查询一条信息
     * @Author: 系统自动生成
     * @Date: 2021-01-18
     * @param vo
     * @return: com.jsb.api.result.ResultModel
     */
    @SystemControllerLog(operation = "【tblLogCon】查询一条信息",type = "info")
    @GetMapping(value = "/getInfoByParam")
    public ResultModel getInfoByParam(GetInfoByParamVo vo){
        log.info("【tblLogCon】查询一条信息 [tblLogCon/getInfoByParam] 接口");
        try {
            TblLogBean infoByParam = tblLogService.getInfoByParam(vo);
            return ResultTools.success(infoByParam);
        } catch (Exception e) {
            e.printStackTrace();
            log.error(String.format("【异常错误】tblLogCon 查询一条信息 ：%s",e.getMessage()));
            return ResultTools.fail("查询失败！");
        }
    }

    /**
     * @Description: 查询多条信息
     * @Author: 系统自动生成
     * @Date: 2021-01-18
     * @param vo
     * @return: com.jsb.api.result.ResultModel
     */
    @SystemControllerLog(operation = "【tblLogCon】查询多条信息",type = "info")
    @GetMapping(value = "/getInfoListByParam")
    public ResultModel getInfoListByParam(GetInfoListByParamVo vo){
        log.info("【tblLogCon】查询多条信息 [tblLogCon/getInfoListByParam] 接口");
        try {
            List<TblLogBean> infoListByParam = tblLogService.getInfoListByParam(vo);
            return ResultTools.success(infoListByParam);
        } catch (Exception e) {
            e.printStackTrace();
            log.error(String.format("【异常错误】tblLogCon 查询多条信息 ：%s",e.getMessage()));
            return ResultTools.fail("查询失败！");
        }
    }

    /**
     * @Description: 分页查询
     * @Author: 系统自动生成
     * @Date: 2021-01-18
     * @param vo
     * @return: com.jsb.api.result.ResultModel
     */
    @SystemControllerLog(operation = "【tblLogCon】分页查询",type = "info")
    @GetMapping(value = "/getPageInfo")
    public ResultModel getPageInfo(GetPageInfoVo vo){
        log.info("【tblLogCon】分页查询 [tblLogCon/getPageInfo] 接口");
        try {
            LayDatas pageInfo = tblLogService.getPageInfo(vo);
            return ResultTools.success(pageInfo);
        } catch (Exception e) {
            e.printStackTrace();
            log.error(String.format("【异常错误】tblLogCon 分页查询 ：%s",e.getMessage()));
            return ResultTools.fail("查询失败！");
        }
    }

    /**
     * @Description: 添加
     * @Author: 系统自动生成
     * @Date: 2021-01-18
     * @param vo
     * @return: com.jsb.api.result.ResultModel
     */
    @SystemControllerLog(operation = "【tblLogCon】添加",type = "info")
    @PostMapping(value = "/add")
    public ResultModel add(AddVo vo){
        log.info("【tblLogCon】添加 [tblLogCon/add] 接口");
        try {
            int add = tblLogService.add(vo);
            if(add>0){
                return ResultTools.success("添加成功！");
            }
        } catch (Exception e) {
            e.printStackTrace();
            log.error(String.format("【异常错误】tblLogCon 添加 ：%s",e.getMessage()));
        }
        return ResultTools.fail("添加失败");
    }

    /**
     * @Description: 修改
     * @Author: 系统自动生成
     * @Date: 2021-01-18
     * @param vo
     * @return: com.jsb.api.result.ResultModel
     */
    @SystemControllerLog(operation = "【tblLogCon】修改",type = "info")
    @PostMapping(value = "/update")
    public ResultModel update(UpdateVo vo){
        log.info("【tblLogCon】修改 [tblLogCon/update] 接口");
        try {
            int update = tblLogService.update(vo);
            if(update>0){
                return ResultTools.success("修改成功！");
            }
        } catch (Exception e) {
            e.printStackTrace();
            log.error(String.format("【异常错误】tblLogCon 修改 ：%s",e.getMessage()));
        }
        return ResultTools.fail("修改失败！");
    }


    /**
     * @Description: 删除
     * @Author: 系统自动生成
     * @Date:  2021-01-18
     * @param vo
     * @return: com.jsb.api.result.ResultModel
     */
    @SystemControllerLog(operation = "【tblLogCon】删除",type = "info")
    @PostMapping(value = "/delete")
    public ResultModel delete(DeleteVo vo){
        log.info("【tblLogCon】删除 [tblLogCon/delete] 接口");
        try {
            int delete = tblLogService.delete(vo);
            if(delete>0){
                return ResultTools.success("删除成功！");
            }
        } catch (Exception e) {
            e.printStackTrace();
            log.error(String.format("【异常错误】tblLogCon 删除 ：%s",e.getMessage()));
        }
        return ResultTools.fail("删除失败！");
    }
}
